
/*
	bootld.c
	
	Bootloader code
	Move .textFW and .dataALL section to 0xa0000000 and 0xa0efc000
*/

#include "bootld.h"

__attribute__ ((section (".tBOOTLD"))) static void xfrBlock(unsigned char* sa, unsigned char* da, uint32 size) {
	
	uint32 cptr = size;
	
	if (size == 0) return;
	
	do{
		--cptr;
		da[cptr] = sa[cptr];
	} while(cptr != 0);
	
	return;
}

__attribute__ ((section (".tBOOTLD"))) void bootld(void) {
	
	unsigned char* sa = (unsigned char*)&LDSATEXTFW;
	unsigned char* da = (unsigned char*)&LDDATEXTFW;
	uint32 size = (uint32)&LDSIZETEXTFW;
	
	xfrBlock(sa, da, size);
	
	sa = (unsigned char*)&LDSADATAALL;
	da = (unsigned char*)&LDDADATAALL;
	size = (uint32)&LDSIZEDATAALL;
	
	xfrBlock(sa, da, size);
	
	return;
}
